<template>
  <div class="card-container">
  <div class="search-container">
      <span class="search-label">车牌号码：</span>
      <el-input clearable placeholder="请输入车牌号码" class="search-main" size="small"
      v-model="params.carNumber"  @clear="getList" />
      
      <span class="search-label">缴纳状态：</span>
      <el-select  placeholder="未选择" v-model="params.paymentStatus" size="small" >
        <el-option label="全部" :value="null" />
        <el-option label="待缴费" :value="0" />
        <el-option label="已缴费" :value="1" />
      </el-select>

      <el-button type="primary" size="small" class="search-btn" @click="getList">查询</el-button>
    </div>


    <div class="table">
      <el-table style="width: 100%" :data="list" >
        <el-table-column type="index" label="序号" />
        <el-table-column label="车牌号码" prop="carNumber" />
        <el-table-column label="收费类型" prop="chargeType" :formatter="formatType"/>
        <el-table-column label="停车总时长" prop="parkingTime"/>
        <el-table-column label="缴纳费用（元）" prop="actualCharge"/>
        <el-table-column label="缴纳状态" prop="paymentStatus" :formatter="formatStatus"/>
        <el-table-column label="缴纳方式" prop="paymentMethod" :formatter="formatMethod"/>
        <el-table-column label="缴纳时间" prop="paymentTime"/>
      </el-table>
    </div>

    <div class="box">
     <el-pagination 
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="params.page"
      :page-size="params.pageSize"
      :page-sizes="[5,10,15,20,25,30]"
      layout="total, prev, pager, next, sizes, jumper"
      :total="this.total">
      </el-pagination> 
      </div>


   
  </div>
</template>



<script>
import { getParkingListAPI } from '@/api/parking'
export default {
  data(){
    return{
      list:[],
      total:0,
      params: {
        carNumber:'',
        paymentStatus:'',
        page: 1,
        pageSize: 10
      }
    }
  },
  mounted(){
    this.getList()

   },

  methods:{

    async getList(){
      const res = await getParkingListAPI(this.params)
      this.list = res.data.rows
      this.total = res.data.total
    },

    //分页
    handleSizeChange(pageSize){ //页码条数
      this.params.pageSize=pageSize
      this.getList()
    },

    handleCurrentChange(page){
      this.params.page=page  //更新当前页码
      this.getList()
    },


      //缴纳状态
      formatStatus(row){
        const status ={
          0:'未缴纳',
          1:'已缴纳'  
        }
        return status[row.paymentStatus]
    },

      //缴纳方式
      formatMethod(row){
        const method ={
          Alipay:'支付宝',
          WeChat:'微信',
          Cash:'现金',
          null:'--'
        }
        return method[row.paymentMethod]
      },

      formatType(row){
        const type ={
          temp:'临时停车',
          card:'月卡',
          null:'--'
        }
        return type[row.chargeType]
      }




  }
}
</script>




<style lang="scss" scoped>

.search-label{
  font-size:14px;
}

.box{
  margin-top:20px;
  //浮动  flex 弹性容器布局（快速实现子元素横向布局）
  // float:right;
  display:flex;
  //默认从左往右 从右往左（右侧开始布局）
  justify-content: flex-end;
}
.card-container {
  padding: 15px;
  background-color: #fff;
}


.search-container {
  display: flex;
  align-items: center;
  border-bottom: 1px solid rgb(237, 237, 237, .9);
  padding-bottom: 20px;
  .search-main {
    width: 220px;
    margin-right: 10px;
  }
  .search-btn{
    margin-left:20px;
  }
}
.create-container{
  margin: 10px 0px;
}
.page-container{
  padding:4px 0px;
  text-align: right;
}
.form-container{
  padding:0px 80px;
}
</style>